import 'package:lx_widgets_library/extension/enum_ex.dart';

// 骑行记录状态
enum RideRecordStatus {
  // 锁车
  ready(0, "Ready"),

  // 近光灯
  doing(1, "Doing"),

  // 鸣笛
  done(2, "Done");

  final int rawValue;
  final String name;
  const RideRecordStatus(this.rawValue, this.name);
  // 通过 title 获取枚举类型
  static RideRecordStatus? getTypeByTitle(String title) =>
      RideRecordStatus.values
          .firstWhereOrNull((activity) => activity.name == title);
  // 通过 rawValue 获取枚举类型
  static RideRecordStatus? getTypeByNum(int rawValue) => RideRecordStatus.values
      .firstWhereOrNull((activity) => activity.rawValue == rawValue);
  // 通过 rawValue 获取 title
  static String? getValue(int rawValue) => RideRecordStatus.values
      .firstWhereOrNull((activity) => activity.rawValue == rawValue)
      ?.name;
}
